package com.heiye.comment.biz.controller;

import com.heiye.comment.biz.model.vo.*;
import com.heiye.comment.biz.service.CommentService;
import com.heiye.framework.biz.operationlog.aspect.ApiOperationLog;
import com.heiye.framework.common.response.PageResponse;
import com.heiye.framework.common.response.Response;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: heiye
 * @date: 2025/07/24 下午3:41
 * @version: v1.0.0
 * @description: 评论业务
 */
@Slf4j
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Resource
    private CommentService commentService;

    /**
     * 发布评论
     *
     * @param publishCommentReqVO
     * @return
     */
    @PostMapping("/publish")
    @ApiOperationLog(description = "发布评论")
    public Response<?> publishComment(@Validated @RequestBody PublishCommentReqVO publishCommentReqVO) {
        return commentService.publishComment(publishCommentReqVO);
    }

    @PostMapping("/list")
    @ApiOperationLog(description = "评论游标分页查询")
    public Response<FindCommentCursorPageListRspVO> findCommentPageList(@Validated @RequestBody FindCommentCursorPageListReqVO findCommentCursorPageListReqVO) {
        return commentService.findCommentPageList(findCommentCursorPageListReqVO);
    }

    @PostMapping("/like")
    @ApiOperationLog(description = "点赞评论")
    public Response<?> likeComment(@Validated @RequestBody LikeCommentReqVO likeCommentReqVO) {
        return commentService.likeComment(likeCommentReqVO);
    }

    @PostMapping("/unlike")
    @ApiOperationLog(description = "评论取消点赞")
    public Response<?> unlikeComment(@Validated @RequestBody UnLikeCommentReqVO unLikeCommentReqVO) {
        return commentService.unlikeComment(unLikeCommentReqVO);
    }

    @PostMapping("/delete")
    @ApiOperationLog(description = "删除评论")
    public Response<?> deleteComment(@Validated @RequestBody DeleteCommentReqVO deleteCommentReqVO) {
        return commentService.deleteComment(deleteCommentReqVO);
    }

    @PostMapping("/best")
    @ApiOperationLog(description = "设置评论为最佳")
    public Response<?> bestComment(@Validated @RequestBody BestCommentReqVO bestCommentReqVO) {
        return commentService.bestComment(bestCommentReqVO);
    }

    @PostMapping("/cancelBest")
    @ApiOperationLog(description = "取消最佳评论")
    public Response<?> cancelBestComment(@Validated @RequestBody CancelBestCommentReqVO cancelBestCommentReqVO) {
        return commentService.cancelBestComment(cancelBestCommentReqVO);
    }
}
